# celery启动命令：celery -A celery_tasks.main worker -l info
# celery_tasks为包名，-l info 显示info以上级别的信息

import os

from celery import Celery

# 设置celery使用django配置文件
if not os.getenv("DJANGO_SETTINGS_MODULE"):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mall.settings.dev'

celery_app = Celery("mall")

# 导入celery配置
celery_app.config_from_object("celery_tasks.config")

# 导入任务，自动注册celery任务
celery_app.autodiscover_tasks(["celery_tasks.sms", "celery_tasks.email",
                               "celery_tasks.html"])